﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinForm2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public static Dictionary<string, string> users = new Dictionary<string,string>();

        //登录
        private void button1_Click(object sender, EventArgs e)
        {
            var uid = user.Text;
            var pwd = this.pwd.Text;
            var usr = users.Where(x=> x.Key==uid && x.Value==pwd)
                .Select(x=> new { key = x.Key, value=x.Value}).FirstOrDefault();
            if (usr!=null)
            {
                
                DbForm2 form2 = new DbForm2();
                this.Visible = false;
                form2.ShowDialog();
                this.Visible = true;
            }
            else
            {
                MessageBox.Show("用户名或密码错误！");
            }
        }

        //打开注册窗口
        private void button2_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            Register register = new Register();
            register.ShowDialog();
            this.Visible = true;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            users.Add("hcj","123456");
        }
    }
}
